import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VersionVO, VersionForm, VersionQuery } from '@/api/pm/version/types';

/**
 * 查询小目标列表
 * @param query
 * @returns {*}
 */

export const listVersion = (query?: VersionQuery): AxiosPromise<VersionVO[]> => {
  return request({
    url: '/pm/version/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小目标详细
 * @param id
 */
export const getVersion = (id: string | number): AxiosPromise<VersionVO> => {
  return request({
    url: '/pm/version/' + id,
    method: 'get'
  });
};

/**
 * 新增小目标
 * @param data
 */
export const addVersion = (data: VersionForm) => {
  return request({
    url: '/pm/version',
    method: 'post',
    data: data
  });
};

/**
 * 修改小目标
 * @param data
 */
export const updateVersion = (data: VersionForm) => {
  return request({
    url: '/pm/version',
    method: 'put',
    data: data
  });
};

/**
 * 删除小目标
 * @param id
 */
export const delVersion = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pm/version/' + id,
    method: 'delete'
  });
};
